/*
 * @Author: ZhaoZhiqi
 * @Date: 2022-08-09 09:47:21
 * @LastEditors: ZhaoZhiqi
 * @LastEditTime: 2022-08-17 13:50:09
 * @Description: 文章管理
 * @FilePath: \tuanfeng-admin-front\src\pages\Question\useTable.ts
 */
import {
    getCSIAPI
} from "../../api/feedback";

import { ref, onMounted, watch } from 'vue'

/**
 * @description: 列表数据 
 * @param {any} filters 筛选条件
 * @return {*}
 */
export default function useTable(filters: any) {
    const tableData = ref([]);
    const loading = ref(false);
    const totalCount = ref(0);

    // 请求数据
    const query = () => {
        loading.value = true;
        getCSIAPI({ ...filters }).then((res: any) => {
            if (res.code === 200) {
                tableData.value = res.data
                totalCount.value = res.totalCount
                console.log(tableData);
            }
            loading.value = false;
        });
    };

    onMounted(query)
    watch(filters, query)

    return {
        tableData,
        loading,
        totalCount,
        query
    }
}